/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.product.core.repository.mapper;

import info.peigen.hotpot.business.product.core.repository.entity.ProductShowCategoryEntity;
import info.peigen.hotpot.business.product.core.repository.entity.ProductStandardProductUnitEntity;
import info.peigen.hotpot.business.product.facade.enums.ProductStatus;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlMapper;
import org.apache.ibatis.annotations.Mapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

import java.util.List;

/**
 * <b>(ProductStandardProductUnitMapper)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2024/4/30
 */
@Mapper
public interface ProductStandardProductUnitMapper extends AbstractBeetlSqlMapper<ProductStandardProductUnitEntity> {
    @Sql("select * from product_spu where spu_id = ?")
    @Select
    ProductStandardProductUnitEntity findBySpuId(String spuId);

    @Sql("delete from product_spu where spu_id = ?")
    @Update
    void deleteBySpuId(String spuId);

    @Sql("select * from product_spu where name = ?")
    @Select
    ProductShowCategoryEntity findByName(String name);

    @Sql("delete from product_spu where name = ?")
    @Update
    void deleteByName(String name);

    @Sql("select * from product_spu where category_id = ?")
    @Select
    List<ProductStandardProductUnitEntity> listByCategoryId(String categoryId);

    @Sql("select * from product_spu where show_category_id = ?")
    @Select
    List<ProductStandardProductUnitEntity> listByShowCategoryId(String showCategoryId);

    @Sql("select * from product_spu where status = ?")
    @Select
    List<ProductStandardProductUnitEntity> listByStatus(ProductStatus status);
}